package fwk.siteManager.managers {	
	
	import fwk.siteManager.BO.PageData;
	import fwk.siteManager.BO.RessourceData;
	import fwk.siteManager.BO.RessourceGroupData;
	import fwk.siteManager.BO.TemplateData;
	import fwk.siteManager.ContainerLoader;
	import fwk.siteManager.interfaces.IDataManager;

	
	
	public class DataManager implements IDataManager
	{
		

		public function DataManager()
		{
			
			
		}
		
		public function getPageData(id:String):PageData
		{
			var node:XML = ContainerLoader.getInstance().xmlTemplates.pages.children().(@uipage == id)[0];
			
			if ( node != null) {
				var item:PageData = new PageData();
				item.init(node);
				
				return item;
			}else {
				return null;
			}
		}
		public function getRessourceGroupData(id:String):RessourceGroupData
		{
			var node:XML = ContainerLoader.getInstance().xmlTemplates.ressources.children().(@id == id)[0];
			
			if ( node != null) {

				var item:RessourceGroupData = new RessourceGroupData();
				item.init(node);
				
				return item;
			}else {
				return null;
			}
			
		}
		public function getTemplateData(id:String):TemplateData
		{
			var node:XML = ContainerLoader.getInstance().xmlTemplates.templates.children().(@uiTemplate == id)[0];
			
			if ( node != null) {

				var item:TemplateData = new TemplateData();
				item.init(node);
				
				return item;
			}else {
				return null;
			}
			
		}
		
		
		
		
		public function getRessourceGlobalData(id:String):RessourceData
		{
			var node:XML = ContainerLoader.getInstance().xmlConfig.ressourcesGlobal.children().(@id == id)[0] ;
			
			if ( node != null) {

				var item:RessourceData = new RessourceData();
				item.init( node);
				
				return item;
			}else {
				return null;
			}
		}
		
		public function getClipStructureData(id:String):RessourceData
		{
			var node:XML = ContainerLoader.getInstance().xmlTemplates.structure.clip.(@id == id)[0] ;
			
			if ( node != null) {

				var item:RessourceData = new RessourceData();
				item.init( node);
				
				return item;
			}else {
				return null;
			}
		}
		
	}
	
	
	
	
}